<?php


/**
 * Notes:
 * PROJECT_NAME : ERP v1.8 重构erp
 * User: 夏鱼儿<397072174@qq.com>
 * Date: 2024/3/15
 * Time: 14:00
 */

namespace app\admin\controller;
use app\admin\model\User;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Response;
use app\admin\model\Goods;

class Search extends BaseAdminController
{


    /**
     *  用户列表
     * @return Response
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function user(): Response
    {
        $param = request()->param();
        $list = [];
        if(count($param)) {
            $model = new User();
            $list  = $model->withSearch('name', $param)->field('id,name')->where('status',1)->select();
        }
        return $this->success('获取成功',$list);
    }


    /**
     * 商品列表
     * @return Response
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function goods(): Response
    {
        $param = request()->param();
        $list = [];
        if(count($param)) {
            $model = new Goods();
            $list  = $model->withSearch('name,no,status', $param)->field('id,name,no')->where('status',1)->select();
        }
        return $this->success('获取成功',$list);
    }
}